package com.redpack.quick.controller;

import com.redpack.quick.common.beans.Result;
import com.redpack.quick.consts.Constants;
import com.redpack.quick.datasource.entity.CompanyEntity;
import com.redpack.quick.service.ICompany;
import com.redpack.quick.utils.ExceptionUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;

/**
 * Created by shuttle on 5/25/17.
 */
@RestController
@RequestMapping(Constants.BASE_URL + "/logo")
@Api(description = "合作机构相关")
public class CompanyController extends BaseController  {

    @Autowired
    private ICompany company;

    @ApiOperation(value = "增加合作机构", notes = "增加合作机构", response = Result.class)
    @RequestMapping(value = "/saveCompany", method = { RequestMethod.POST}, produces = "application/json;charset=utf-8")
    public Result<CompanyEntity> getHotLoan(@RequestBody CompanyEntity entity){
        CompanyEntity bean = company.save(entity);
        try {
            return successResult(bean);
        }catch (Exception e){
            ExceptionUtils.printException("getLogo controller报错：", e);
            return failResult(e);
        }
    }
}
